<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    div {
      width: 20px;
      height: 20px;
      background-color: red;
      position: absolute;
      left: 200px;
    }
  </style>
</head>

<body>

  <div></div>

  <script>
    function obj() { }
    let speed = 0
    const div = document.querySelector('div')
    let startPosLeft = 20//设置雪花随机的开始x值的大小
    div.style.left = startPosLeft + 'px'

    setInterval(function (e) {
      div.style.left = speed + 'px'
      speed += 10
    }, 500)
  </script>
</body>

</html>